#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_copy_file.py
# author:张仁
# datetime:2021/3/16 20:39
# software: PyCharm
"""
      将一个文件夹下的某个文件,拷贝到另外一个文件夹下去
"""
import os


def copy_file(src, dest):
    """
        param:
            src: 源文件路径
            dest：目标文件路径

        如果源文件不存在则抛出FileNotFoundError异常
    """
    if os.path.exists(src):
        with open(src, "r") as src_file:
            str1 = src_file.read()
        with open(dest, "w") as dest_file:
            dest_file.write(str1)
            print("copy操作执行成功！")
    else:
        raise FileNotFoundError("文件不存在！请检查源文件的路径是否正确")
